﻿using FairyGUI;
using System;

/// <summary>
/// 主界面UI
/// </summary>
public class UIHomeWindow : UIBaseWindow {

    UIHome_TopBar _topBarCtrl;
	UIHome_GundongMsg _scrollMsg;

    public UIHomeWindow()
    {
        // 初始化界面
        base.Init(UIPackage.CreateObject("主界面", "主界面").asCom);

        // 初始化顶部工具栏
        _topBarCtrl = new UIHome_TopBar(uiComp.GetChild("顶部条").asCom);

		// 滚动消息
		_scrollMsg = new UIHome_GundongMsg (uiComp.GetChild("滚动公告").asCom);
		_scrollMsg.SetMessage (DataKernel.inst.annInfo.getAnnRandom ());
		_scrollMsg.StartScroll ();

        // 初始化创建房间按钮
        GButton createRoomBtn = uiComp.GetChild("创建房间按钮").asButton;
        createRoomBtn.onClick.Add(()=> {
            UIHome_CreateRoom.Popup();
        });

        // 初始化加入房间按钮
        GButton joinRoomBtn = uiComp.GetChild("加入房间").asButton;
        joinRoomBtn.onClick.Add(() => {
            UIHome_JoinRoom.Popup();
        });
    }

    public override void OnExit()
    {
		_scrollMsg.StopScroll ();
        uiComp.Dispose();
    }
}
